extern crate lookup;
use lookup::*;


#[test]
fn test_simple_cons_parser() {
    let p=Parser::CHAR('a')+Parser::CHAR('b');
    assert_eq!(p, Parser::CONS(Box::new(Parser::CHAR('a')),Box::new(Parser::CHAR('b'))));
}

#[test]
fn test_simple_or_parser() {
    let p=Parser::CHAR('a')|Parser::CHAR('b');
    assert_eq!(p, Parser::OR(Box::new(Parser::CHAR('a')),Box::new(Parser::CHAR('b'))));
}

#[test]
fn test_simple_parser() {
    let p=Parser::CHAR('a');
    assert_eq!(p.parse(&String::from("a"),0), Some(Result{t:ResultType::CHAR,pos:0,length:1}));
}

#[test]
fn test_simple_parser_maybe() {
    let p=Parser::MAYBE(Box::new(Parser::CHAR('a')));
    assert_eq!(p.parse(&String::from("a"),0), Some(Result{t:ResultType::MAYBE(Box::new(Result{t:ResultType::CHAR,pos:0,length:1})),pos:0,length:1}));
}

#[test]
fn test_simple_parser_maybe_none() {
    let p=Parser::MAYBE(Box::new(Parser::CHAR('a')));
    assert_eq!(p.parse(&String::from("c"),0), Some(Result{t:ResultType::MAYBE(Box::new(Result{t:ResultType::EMPTY,pos:0,length:0})),pos:0,length:0}));
}